﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using QingzimaScenario;
using QingzimaLogicModel;

namespace QingzimaWebClient.Controllers
{
    public class HoutaiJiankangmimaController : Controller
    {
        //
        // GET: /HoutaiJiankangmima/

        public ActionResult List()
        {
            ViewBag.JiankangmimaList = JiankangmimaScenario.HuoquModels();
            return View();
        }

        public ActionResult Add()
        {
            return View();
        }

        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Add(JiankangmimaLM JiankangmimaLM)
        {
            if (string.IsNullOrEmpty(JiankangmimaLM.Biaoti))
            {
                ViewBag.State = "请输入标题";
            }
            else
            {
                JiankangmimaLM.Neirong = Request.Form.Get("HtmlTextArea");

                JiankangmimaScenario.Tianjia(JiankangmimaLM);
                return RedirectToAction("List");
            }
            return View();
        }

        public ActionResult Update(string key)
        {
            JiankangmimaLM JiankangmimaLM = JiankangmimaScenario.HuoquByKey(key);
            ViewBag.Neirong = JiankangmimaLM.Neirong;
            return View(JiankangmimaLM);
        }

        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Update(JiankangmimaLM JiankangmimaLM)
        {
            JiankangmimaLM.Neirong = Request.Form.Get("HtmlTextArea");

            JiankangmimaScenario.Tianjia(JiankangmimaLM);
            return RedirectToAction("List");
        }

        public ActionResult Del(string key)
        {
            JiankangmimaScenario.Shanchu(key);
            return RedirectToAction("List");
        }
    }
}
